package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
	"github.com/zhaocy/fyne-theme"
)

func main() {
	myApp := app.New()
	myApp.Settings().SetTheme(themex.Themex())
	myWin := myApp.NewWindow("弹窗")

	box := container.NewVBox(
		widget.NewLabel("the label"),
		&widget.Button{Text: "关闭模式窗口"},
	)
	// 创建弹窗
	popWin := widget.NewPopUp(box, myWin.Canvas())
	btn := widget.NewButton("显示", func() {
		popWin.ShowAtPosition(fyne.NewPos(
			myWin.Canvas().Size().Width/2- popWin.MinSize().Width/2,
			myWin.Canvas().Size().Height/2-popWin.MinSize().Height/2))
	})

	//创建模式弹窗
	popWinModal := widget.NewModalPopUp(box, myWin.Canvas())
	btn2 := widget.NewButton("模式显示", func() {
		popWinModal.Show()
	})
	//关闭模式窗口
	box.Objects[1].(*widget.Button).OnTapped = func() {
		popWinModal.Hide()
	}
	c := container.NewVBox(btn, btn2)
	myWin.SetContent(c)
	myWin.Resize(fyne.NewSize(550, 450))
	myWin.ShowAndRun()
}
